package com.wudao.ncmplay.util;

import java.util.Map;

/**
 * @Description 处理map相关数据
 *
 * @author ZhengGuoFen
 * @Date  2022/6/13
 **/
public class MapUtils
{
    /**
     * map转字符串，用于发送http请求转义双引号
     *
     * @param map
     * @return
     */
    public static String map2String(Map<String, String> map) {
        StringBuilder builder = new StringBuilder();
        builder.append("\"{\"");

        map.forEach((k, v) -> {
            builder.append(k).append("\":\"").append(v).append("\",");
        });

        if (map.size() > 0) {
            builder.deleteCharAt(builder.length() - 1);
        }

        builder.append("}\"");
        return builder.toString();
    }
}
